﻿require(["jquery", "kendo", "bootstrap", "kendo.culture"], function ($, kendo) {
    // do stuff with AnotherModule
    //console.log("w00t! This code only runs on the index.cshtml page");
    kendo.culture("en-GB");
    $(document).ready(function () {
        $('.tt').tooltip({ html: true });
    });
});



//require(["jquery", "kendo"], function ($, kendo) {
//    $(document).ready(function () {
//        kendo.ui.progress($("#loading"), true);
//    });
//    $(window).load(function() {
//        kendo.ui.progress($("#loading"), false);
//    });
//});

require([
	"angular",
	"jquery",
    "jquery.cookie",
	"angularModules",
    "blob",
    "filesaver"
],
function (angular, $, app) {
    angular.bootstrap($(document), ["ShipApp"]);
});

function onResize(e) {
require(["jquery.cookie", "kendo"], function () {
    
    var grid = $("#grid").data("kendoGrid");

        var state = kendo.stringify({
            columns: grid.columns
        });

        $.cookie("columnsState", state, { expires: 365 * 10 });
    
});
}

function onDataBound(e) {
    require(["jquery.cookie"], function () {
        
        var cookies = $.cookie("columnsState");
            if (cookies != undefined && cookies != {}) {
                var state = JSON.parse(cookies);
                if (state) {
                    for (var i = 0; i < state.columns.length; i++) {
                        if (state.columns[i].width != undefined) {
                            resize(i, state.columns[i].width);
                        }
                    }
                }
            }
       
    });
}
function resize(idx, width) {
    require(["jquery"], function () {
        
            $("#grid .k-grid-header-wrap") //header
                .find("colgroup col")
                .eq(idx)
                .css({ width: width });

            $("#grid .k-grid-content") //content
                .find("colgroup col")
                .eq(idx)
                .css({ width: width });
        
    });
}

//require(['boot'], function () {
//    // Load the specs
//    require([
//    'unitTests'
//    ], function () {
//        // Initialize the HTML Reporter and execute the environment (setup by `boot.js`)
//        window.onload();
//    });
//});